
//分装一个 x-y的随机数
function randomMath (x,y){
  return Math.round(Math.random()*(y-x)+x)
}

const p = new Promise((resolve, reject)=>{
  console.log('开始执行任务！！')

    setTimeout(()=>{
      let cont = Number(randomMath(1,10))
      console.log('执行任务A=>')
      if (cont > 5){
        resolve('任务A执行完成~~~~~')
      }else if (cont <= 5){
        reject('任务A执行不通过！！！')
      }
    },1500)

})
  .then(
    (value)=>{
      return new Promise((resolve, reject)=>{
        setTimeout(()=>{
          console.log(value)
          let cont = Number(randomMath(1,10))
          if (cont > 5){
            console.log('执行任务B=>')
            resolve('任务B执行完成~~~~~')
          }else if (cont <= 5){
            reject('任务A执行不通过！！！')
          }
        },1500)
      })
    },
    (reason)=>{
      return new Promise((resolve, reject)=>{
        setTimeout(()=>{
          console.log(reason)
          console.log('转变，执行任务C')
          let cont = Number(randomMath(1,10))
          if (cont > 5){
            console.log('开始执行任务C=>')
            resolve('任务C执行完成~~~~~')
          }else if (cont <= 5){
            reject('任务C执行不通过！！！')
          }
        },1500)
      })
    })
  .then(value => {
    setTimeout(()=>{
      console.log(value)
    },2000)
  })
